 [ -z "$2" ] && file="run.log"

echo "$1 Ne(5):" 
grep "Matrix product count" $1 | awk '{print $4}'|xargs -n 2| awk '{print $1", "}' |xargs| sed -r 's/\x1B\[[0-9;]*[mK]//g'|sed -e "s/^/old=[/" -e "s/,[ ]*$/];/" | tee $1_5.txt
echo "$1 Ne(2):" 
grep "Matrix product count" $1 | awk '{print $4}'|xargs -n 2| awk '{print $2", "}' |xargs| sed -r 's/\x1B\[[0-9;]*[mK]//g' |sed -e "s/^/old2=[/" -e "s/,[ ]*$/];/" |tee $1_2.txt
echo "$file Ne(5):" 
grep "Matrix product count" ${file} | awk '{print $4}'|xargs -n 2| awk '{print $1", "}' |xargs| sed -r 's/\x1B\[[0-9;]*[mK]//g'|sed -e "s/^/new=[/" -e "s/,[ ]*$/];/" | tee ${file}_5.txt
echo "$file Ne(2):" 
grep "Matrix product count" ${file} | awk '{print $4}'|xargs -n 2| awk '{print $2", "}' |xargs| sed -r 's/\x1B\[[0-9;]*[mK]//g' |sed -e "s/^/new2=[/" -e "s/,[ ]*$/];/" |tee ${file}_2.txt

cat $1_5.txt $1_2.txt ${file}_5.txt ${file}_2.txt > plot_tmp.m
echo  "$file is x-axis"
cat <<EOL >> plot_tmp.m
figure;
subplot(1, 2, 1);
hold on;
plot(new, old, '*');
x=min(new):max(new);
plot(x,x);
title('NE5');
hold off;

subplot(1, 2, 2);
hold on;
plot(new2, old2, '*');
x=min(new2):max(new2);
plot(x,x);
title('NE2');
hold off;
waitfor(gcf);
EOL

octave plot_tmp.m
